function [ fout, tout ] = resampling( fin, fsin, fsout )

m = lcm(fsin, fsout);
u = m / fsin;
d = m / fsout;

if (u > 1000)
    error('up scale factor too big');
end

if (u > 1)
    [fout, tout] = upsampling(fin, fsin, fsin*u);
    if (d > 1)
        [fout, tout] = downsampling(fout, fsin*u, fsout);
    end
elseif (d > 1)
    [fout, tout] = downsampling(fin, fsin, fsout);
else
    tout = (1/fsin) * linspace(0, size(fin, 2), size(fin, 2)); 
    fout = fin;
end

end

